<?php
class FeedAction extends PublicAction
{
    public function show()
    {
        $this->display();
    }

    public function sub()
    {
        dump($_POST);

    }

    public function read()
    {
        $catehash = $_GET["category"];
        
        if(empty($catehash))
            return;

        $catehash = str_replace("-",",",$catehash);
        $cateDao = D("Category");
        $cateList = $cateDao->where("categoryhash IN ( $catehash )")->findAll();
        $cateTitle = array();
        for($i=0; $i<count($cateList);$i++)
            $cateTitle[] = $cateList[$i]["title"];
        //查询最新新闻
        $ln = 20;

        $newsDao = D("News");
        $newsList = $newsDao->where("categoryhash IN (  $catehash )")->order("date DESC")->limit($ln)->findAll();
 
        import("@.ORG.RSS");
        $rss = new Rss("您订阅的LOOKER新闻频道[".implode(",",$cateTitle)."]的最近更新", __APP__."/Feed/read/category/".$_GET["category"],"Looker新闻订阅",__PUBLIC__."images/rss.gif");

        foreach($newsList as $news){
            $rss->addItem($news["title"], __APP__."/News/view/news/".$news["newshash"],$news["intro"],date("m/d H:m",$news['date']));
        }

        $rss->display();
    }
}
?>